﻿using System;
using System.Security.Claims;
using System.Threading.Tasks;
using Data.Entities;
using Identity.Entities;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;

namespace Identity.Core
{
    public class AppSignInManager : SignInManager<SysUser, Guid>
    {
        public AppSignInManager(AppUserManager userManager)
            : base(userManager, OwinContextHelper.CurrentOwinContext.Authentication)
        {

        }

        public override async Task<ClaimsIdentity> CreateUserIdentityAsync(SysUser user)
        {
            var userIdentity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
            return userIdentity;
        }

        //public static AppSignInManager Create(IdentityFactoryOptions<AppSignInManager> options, IOwinContext context)
        //{
        //    return new AppSignInManager(context.GetUserManager<AppUserManager>(), context.Authentication);
        //}
    }
}